package com.css.apps.base.common.action;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import com.css.core.model.IServiceResult;
import com.css.util.Ajax;
import com.css.util.Messages;
import com.css.webbase.webwork.WebworkUtil;
import com.css.webbase.webwork.action.UserAction;
/**
 * 获取文件传输令牌<br/>
 * 每个合法的登陆用户皆可以获取,用以实现文件上传
 * @author paladin
 */
@SuppressWarnings("serial")
public class GetTransferToken extends UserAction {
	private static Log log = LogFactory.getLog(ClearCache.class);
	@Override
	protected String userGo() {
		 try {
			//暂时使用session作为token
			String token = WebworkUtil.getHttpSession().getId();
			//设置token
			com.css.db.memcached.MemCachedFactory.set(token, "0", com.css.core.configuration.ConfigurationManager.getCacheTime());
			setResult(Ajax.JSONResult(IServiceResult.RESULT_OK,Messages.getString("systemMsg.success"),token));
		} catch (Exception ex) {
			String msg=Messages.getString("systemMsg.failed");
			log.error(ex.getMessage(), ex);
			setResult(Ajax.JSONResult(IServiceResult.RESULT_FAILED,msg));
			return ERROR;
		}		 
		return SUCCESS;
	}

}
